# Contributor: Clayton Craft <clayton@craftyguy.net>
# Maintainer: team/kde <clayton@craftyguy.net>
pkgname=kstars
pkgver=3.7.0
pkgrel=0
pkgdesc="Astronomy software"
url="https://kde.org/applications/education/kstars"
# arm, riscv64: no support in deps
# ppc64le: build fails and I don't care about that arch
arch="all !armv7 !armhf !ppc64le !riscv64"
license="GPL-2.0-or-later"
makedepends="
	cfitsio-dev
	cmake
	eigen-dev
	extra-cmake-modules
	gsl-dev
	kconfig5
	kconfigwidgets5
	kcoreaddons5
	kcrash5
	kdoctools5-dev
	ki18n5
	kio5
	knewstuff5-dev
	knotifications5
	knotifyconfig5-dev
	kplotting5-dev
	kwidgetsaddons5
	kxmlgui5
	libindi-dev
	libnova-dev
	libraw-dev
	libxisf-dev
	qt5-qtbase-dev
	qt5-qtdatavis3d-dev
	qt5-qtdeclarative-dev
	qt5-qtquickcontrols2-dev
	qt5-qtsvg-dev
	qt5-qtwebsockets-dev
	qtkeychain-dev
	samurai
	stellarsolver-dev
	wcslib-dev
"
subpackages="$pkgname-dev $pkgname-doc"
source="
	https://download.kde.org/stable/kstars/kstars-$pkgver.tar.xz
	tests-disable-ngc4535-autofocus3.patch
	"

build() {
	cmake -B build -G Ninja \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_INSTALL_LIBDIR=lib \
		-DCMAKE_BUILD_TYPE=None
	cmake --build build
}

check() {
	# Note: excluded tests fail because they cannot find TZrules.dat and other
	# things in the 'data' dir. Seems like test framework would allow
	# specifying or overriding the search dir since data is in $srcdir, but I
	# couldn't figure it out yet, so disabling tests...
	ctest --test-dir build --output-on-failure \
		-E "StarCorrespondenceTest|Test(ArtificialHorizon|CatalogDownload|EkosCapture|EkosFilterWheel|EkosFocus|EkosMeridianFlipState|EkosMount|EkosScheduler|EkosSchedulerOps|EkosSimulator|KSPaths|PolarAlign)"
}

package() {
	DESTDIR="$pkgdir" cmake --install build
}

sha512sums="
b62ccc4706dcc23aee2098c8b7614514110b22fd8150efe6119be056d9bd17f29fcf1943b0282364b02e02b32d1d7cfd2f1175a2cf79e4f4d0085865b4716c79  kstars-3.7.0.tar.xz
16967f51398456e259f351f91307d57885cbe9778199521c6b9c157d6b19477a49a055311d3d75ce10b9b3266211344aee153b4c09881dd553ebd28d2692684c  tests-disable-ngc4535-autofocus3.patch
"
